package com.example.msgBoard.service.impl;

import com.example.msgBoard.mapper.MessageMapper;
import com.example.msgBoard.model.Message;
import com.example.msgBoard.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MessageServiceImpl implements MessageService {
    @Autowired
    private MessageMapper messageMapper;

    @Override
    public void addMessage(Message message) {
        messageMapper.insertMessage(message);
    }

    @Override
    public Message getMessageById(int id) {
        return messageMapper.getMessageById(id);
    }

    @Override
    public List<Message> getAllRootMessages() {
        return messageMapper.getAllRootMessages();
    }

    @Override
    public List<Message> getRepliesByParentId(int parentId) {
        return messageMapper.getRepliesByParentId(parentId);
    }

    @Override
    public void updateMessage(Message message) {
        messageMapper.updateMessage(message);
    }

    @Override
    public void deleteMessage(int id) {
        messageMapper.deleteMessage(id);
    }
}
